package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Setter@Getter
@JsonIgnoreProperties("handler")//转成json的时候忽略序列化该属性
public class StrategyCatalog extends BaseDomain{

    private String name;//攻略分类名称

    private Strategy strategy;//攻略

    private Integer sequence;//序号

    private Boolean state;//状态

    private List<StrategyDetail> details =new ArrayList<>();

    public String getStateName(){
        String temp ="禁用";
        if(state){
            temp="启用";
        }
        return temp;
    }
    public String getJson(){
        Map<String,Object> map = new HashMap();
        map.put("id",id);
        map.put("name",name);
        if(strategy!=null) {
            map.put("strategyId", strategy.getId());
            map.put("strategyTitle", strategy.getTitle());
        }
        map.put("sequence",sequence);
        map.put("state",state);
        return JSONUtil.toJSONString(map);
    }

}